package cn.rongdao.jrkabao.ui.loan.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerAdapter;
import com.mifengkong.frtools.ui.adapter.recyclerview.FRBaseRecyclerViewHolder;

import cn.rongdao.jrkabao.R;
import cn.rongdao.jrkabao.constant.InfoConstant;
import cn.rongdao.jrkabao.bean.loan.MultiPushBean;
import cn.rongdao.jrkabao.ui.loan.adapter.listener.MutliPustitemClickListener;
import cn.rongdao.jrkabao.ui.loan.adapter.viewholder.MultiPushApplingViewHolder;
import cn.rongdao.jrkabao.ui.loan.adapter.viewholder.MultiPushCompletedViewHolder;
import cn.rongdao.jrkabao.ui.loan.adapter.viewholder.MultiPushNotAppliedViewHolder;
import cn.rongdao.jrkabao.ui.loan.adapter.viewholder.MultiPushRepaymentViewHolder;


/**
 * Created by jack on 17/5/16
 */

public class MultiPushItemAdapter extends FRBaseRecyclerAdapter<MultiPushBean.ProductListBean, FRBaseRecyclerViewHolder<MultiPushBean.ProductListBean>> {

    private MutliPustitemClickListener mutliPustitemClickListener;

    public MultiPushItemAdapter(Context context, MutliPustitemClickListener mutliPustitemClickListener) {
        super(context);
        this.mutliPustitemClickListener = mutliPustitemClickListener;
    }

    @Override
    public FRBaseRecyclerViewHolder<MultiPushBean.ProductListBean> onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType) {
            case InfoConstant.ITEM_LOAN_STATUS_NOT_APPLIED:
                return new MultiPushNotAppliedViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_multi_push_not_applied, parent, false),mutliPustitemClickListener);
            case InfoConstant.ITEM_LOAN_STATUS_COMPLETED:
                return new MultiPushCompletedViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_multi_push_completed, parent, false),mutliPustitemClickListener);
            case InfoConstant.ITEM_LOAN_STATUS_APPLING:
                return new MultiPushApplingViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_multi_push_appling, parent, false),mutliPustitemClickListener);
            case InfoConstant.ITEM_LOAN_STATUS_REPAYMENT:
                return new MultiPushRepaymentViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_multi_push_repayment, parent, false),mutliPustitemClickListener);
        }
        return new MultiPushNotAppliedViewHolder(LayoutInflater.from(getContext()).inflate(R.layout.item_multi_push_not_applied, parent, false),mutliPustitemClickListener);
    }

    @Override
    public int getItemViewType(int position) {
        int type = getDataList().get(position).getType();
        switch (type) {
            case InfoConstant.ITEM_LOAN_STATUS_NOT_APPLIED:
                return InfoConstant.ITEM_LOAN_STATUS_NOT_APPLIED;
            case InfoConstant.ITEM_LOAN_STATUS_COMPLETED:
                return InfoConstant.ITEM_LOAN_STATUS_COMPLETED;
            case InfoConstant.ITEM_LOAN_STATUS_APPLING:
                return InfoConstant.ITEM_LOAN_STATUS_APPLING;
            case InfoConstant.ITEM_LOAN_STATUS_REPAYMENT:
                return InfoConstant.ITEM_LOAN_STATUS_REPAYMENT;
        }
        return InfoConstant.ITEM_LOAN_STATUS_NOT_APPLIED;
    }
}
